package sql

import org.apache.spark.SparkConf
import org.apache.spark.sql.{DataFrame, SparkSession}

object SparkSqlOracle {
  def main(args: Array[String]): Unit = {
    val sparkconf = new SparkConf().setMaster("local[*]").setAppName("sparkSql")
    val spark = SparkSession.builder().config(sparkconf).getOrCreate()
    //读取mysql数据库
    val df: DataFrame = spark.read
      .format("jdbc")
      .option("url", "jdbc:oracle:thin:@//atgdlx22.cn-dgg01.nexperia.com:1530:APGTCM")
      .option("driver", "oracle.jdbc.driver.OracleDriver")
      .option("user", "APG_TCM_SAP")
      .option("password", "APG_TCM_SAP")
      .option("dbtable", "TBLIF264COMPONENT_BATCH")
      .load()
    df.show(20)
  }
}
